package com.richapp.launcher.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;

import com.richapp.launcher.utils.Tools;

import java.util.Timer;
import java.util.TimerTask;

public class AlarmReceiver extends BroadcastReceiver {
    private  Context Icontext;
    @Override
    public void onReceive(Context context, Intent intent) {
        Toast.makeText(context, "亲！我已经为您服务24小时了好累，人家要重启一下下啦~~", Toast.LENGTH_LONG).show();
        Log.v("AlarmReceiver","重启时间到");
        Icontext=context;
        delayed();
    }



    /**
     * 延迟器
     */
    public void  delayed(){
        TimerTask task = new TimerTask() {
            @Override
            public void run() {
                /**
                 *要执行的操作 此处做重启主机操作
                 */
                Tools.restartSystem(Icontext);
            }
        };
        Timer timer = new Timer();
        timer.schedule(task, 1000*8);//8秒后执行TimeTask的run方法


    }
}
